// pages/detail/detail.js
var app = getApp()
var restaurantId;
var articleId;
var isMember;
Page({

  data: {
    userInfo:[],
    list: [],
    article:{},
    indicatorDots: true,
    autoplay: false,
    interval: 3000,
    duration: 1000,
    errorHidden:true,
    errorText:"",
    imgwidth: 0,
    imgheight: 0
  },

  
  onLoad: function (options) {
    console.log(options)
    restaurantId = options.restaurantId;
    articleId = options.articleId;
    isMember = options.isMember;

    var that = this
    app.getUserInfo(function (userInfo) {
      //更新数据
      that.setData({
        userInfo: userInfo
      })
    })
    
    wx.request({
      url: app.globalData.path + '/weixin/coffee/xcx/coffeePass/detail',
      data:{
        articleId:articleId  
      },
      method: 'GET',
      success: function (res) {
        console.log(res.data)
        that.setData({
          list: res.data.restaurantList,
          article: res.data.article
        })
      }
    })
  },
  goEnjoy:function(){
    if(isMember == 'true'){
      wx.navigateTo({
        url: '../enjoy/enjoy?restaurantId=' + restaurantId,
      })
    }else{
        this.setData({
        errorHidden: false,
        errorText: "您不是WISH VIP，快开通会员来享用吧！"
      })
    }
    
  },
  closeErrorDialog: function () {
    this.setData({
      errorHidden: true
    })
  },
  imageLoad: function (e) {
    var $width = e.detail.width,    //获取图片真实宽度
      $height = e.detail.height,
      ratio = $width / $height;    //图片的真实宽高比例
    var viewWidth = 750,           //设置图片显示宽度，左右留有16rpx边距
         viewHeight = 750 / ratio;    //计算的高度值
    this.setData({
      imgwidth: viewWidth,
      imgheight: viewHeight
    })  
  }

})